package com.study.springboot.controller;


import com.study.springboot.common.mvc.BaseController;
import com.study.springboot.common.mvc.RespData;
import com.study.springboot.model.entity.Student;
import com.study.springboot.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Admin
 * @since 2021-11-21
 */
@RestController
@RequestMapping("/student")
public class StudentController extends BaseController {

    @Autowired
    StudentService studentService;

    @PostMapping("/add")
    public RespData add(@RequestBody Student student){
        studentService.add(student);
        return success();
    }

    @GetMapping("/queryById/{id}")
    public RespData<Student> queryById(@PathVariable("id")Long id){
        return success(studentService.queryById(id));
    }

    @GetMapping("/queryCount")
    public RespData<Integer> queryCount(){
        return success(studentService.queryCount());
    }

}

